<?php
/**
 * 经验值管理
 *
 * @author karl <karl.tang@aiyuangong.com>
 * @link http://www.aiyuangong.com
 */

namespace app\admin\controller\member;

use app\admin\Controller;
use think\Config;
use think\Db;

class ExppointsLog extends Controller {

    use \app\admin\traits\controller\Controller;

    /**
     * 经验值规则设置页面
     */
    public function exppoints_setting() {
        $exppointsArr = Config::get('expoints_setting');
        $this->view->assign('exppoints', $exppointsArr);
        return $this->view->fetch();
    }

    public function index() {
        //操作阶段列表
        $stageList = ['login'=>'会员登录','comments'=>'商品评论','order'=>'订单消费']; 
        $name = $this->request->param('name/s', '');
        $stime = $this->request->param('stime/s', '');
        $etime = $this->request->param('etime/s', '');
        $exp_stage = $this->request->param('exp_stage/s', '');
        $exp_desc = $this->request->param('exp_desc/s', '');
        $where = [];
        if ($name) {
            $where['exp_membername'] = ['like', '%' . $name . '%'];
        }
        if ($stime) {
            $where['exp_addtime'] = ['egt', strtotime($stime.' 00:00:00')];
        }
        if($etime){
            $where['exp_addtime'] = ['elt', strtotime($etime.' 00:00:00')];
        }
        if ($exp_stage) {
            $where['exp_stage'] = $exp_stage;
        }
        if ($exp_desc) {
            $where['exp_desc'] = ['like', '%' . $exp_desc . '%'];;
        }
        $list = $this->datalist(model('exppoints_log'),$where);
        $this->view->assign('stage_list', $stageList);
        return $this->view->fetch();
    }

}
